
/**
 * @author Robert Curtis
 * @version 1.0
 * Purpose of program: This class represents a Pentagon that can be displayed in a graphics
 * context
 **/

import java.awt.*;

public class Pentagon extends Shape
{
	// Instance variables
	private int sideLength;
	private Polygon polygon;


	/**
	 * Pentagon Constructor
	 * @param x
	 * @param y
	 * @param color
	 * @param width
	 * @param height
	 */
	public Pentagon(int x, int y, Color color,
			int sideLength)
	{
		super(x, y, color);
		this.sideLength = sideLength;
	}

	/**
	 * Pentagon algorithm informed by:
	 * http://www.java2s.com/Code/Java/2D-Graphics-GUI/DrawaPolygon.htm
	 */
	public void draw(Graphics g)
	{
		g.setColor(getColor());
		polygon  = new Polygon();
		
		//Hope you paid attention in Trig/Calculus class!
		for (int i = 0; i < 5; i++)
		      polygon.addPoint(
		    		  (int) (this.getX() + sideLength * Math.cos(i * 2 * Math.PI / 5)),
		              (int) (this.getY() + sideLength * Math.sin(i * 2 * Math.PI / 5)));

		    g.fillPolygon(polygon);
	}

	public int getHeight()
	{
		return sideLength;
	}

	public int getWidth()
	{
		return sideLength;
	}
}